{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "6598d952",
   "metadata": {},
   "source": [
    "# 项目2 P35"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "1a10fbfd",
   "metadata": {},
   "outputs": [],
   "source": [
    "from datetime import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "9e11780b",
   "metadata": {},
   "outputs": [],
   "source": [
    "import random\n",
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "3c5f45d0",
   "metadata": {},
   "outputs": [],
   "source": [
    "odds = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "0aa1c829",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This minute seems a little odd.\n",
      "This minute seems a little odd.\n",
      "Not an odd minute.\n",
      "This minute seems a little odd.\n",
      "Not an odd minute.\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    right_this_minute = datetime.today().minute\n",
    "    if right_this_minute in odds:\n",
    "        print(\"This minute seems a little odd.\")\n",
    "    else:\n",
    "        print(\"Not an odd minute.\")\n",
    "    wait_time = random.randint(1,60)\n",
    "    time.sleep(wait_time)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "62052508",
   "metadata": {},
   "source": [
    "### 课堂上的补充"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "808327e6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "38\n",
      "现在是秒/时间为偶数\n",
      "等待时间为: 1\n",
      "39\n",
      "现在是秒/时间为奇数\n",
      "等待时间为: 4\n",
      "43\n",
      "现在是秒/时间为奇数\n",
      "等待时间为: 4\n",
      "47\n",
      "现在是秒/时间为奇数\n",
      "等待时间为: 3\n",
      "50\n",
      "现在是秒/时间为偶数\n",
      "等待时间为: 1\n"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "import random\n",
    "import time\n",
    "odds = [1,3,5,7,9,11,13,15,17,19,\n",
    "        21,23,25,27,29,31,33,35,37,39,\n",
    "        41,43,45,47,49,51,53,55,57,59]\n",
    "# right_this_second 是一个变量，是随着当前时间分钟数不断变化的一个值\n",
    "\n",
    "for i in range(5):\n",
    "    right_this_second = datetime.today().second\n",
    "    if right_this_second in odds:\n",
    "        print(right_this_second)\n",
    "        print(\"现在是秒/时间为奇数\")\n",
    "    else:\n",
    "        print(right_this_second)\n",
    "        print(\"现在是秒/时间为偶数\")\n",
    "    wait_time = random.randint(1,5)\n",
    "    print(\"等待时间为:\", wait_time)\n",
    "    time.sleep(wait_time)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "599544dd",
   "metadata": {},
   "source": [
    "# 项目3 P44"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "2570e0df",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottles of beer on the wall.\n",
      "99 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "98 bottles of beer on the wall.\n",
      "\n",
      "98 bottles of beer on the wall.\n",
      "98 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "97 bottles of beer on the wall.\n",
      "\n",
      "97 bottles of beer on the wall.\n",
      "97 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "96 bottles of beer on the wall.\n",
      "\n",
      "96 bottles of beer on the wall.\n",
      "96 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "95 bottles of beer on the wall.\n",
      "\n",
      "95 bottles of beer on the wall.\n",
      "95 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "94 bottles of beer on the wall.\n",
      "\n",
      "94 bottles of beer on the wall.\n",
      "94 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "93 bottles of beer on the wall.\n",
      "\n",
      "93 bottles of beer on the wall.\n",
      "93 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "92 bottles of beer on the wall.\n",
      "\n",
      "92 bottles of beer on the wall.\n",
      "92 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "91 bottles of beer on the wall.\n",
      "\n",
      "91 bottles of beer on the wall.\n",
      "91 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "90 bottles of beer on the wall.\n",
      "\n",
      "90 bottles of beer on the wall.\n",
      "90 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "89 bottles of beer on the wall.\n",
      "\n",
      "89 bottles of beer on the wall.\n",
      "89 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "88 bottles of beer on the wall.\n",
      "\n",
      "88 bottles of beer on the wall.\n",
      "88 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "87 bottles of beer on the wall.\n",
      "\n",
      "87 bottles of beer on the wall.\n",
      "87 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "86 bottles of beer on the wall.\n",
      "\n",
      "86 bottles of beer on the wall.\n",
      "86 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "85 bottles of beer on the wall.\n",
      "\n",
      "85 bottles of beer on the wall.\n",
      "85 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "84 bottles of beer on the wall.\n",
      "\n",
      "84 bottles of beer on the wall.\n",
      "84 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "83 bottles of beer on the wall.\n",
      "\n",
      "83 bottles of beer on the wall.\n",
      "83 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "82 bottles of beer on the wall.\n",
      "\n",
      "82 bottles of beer on the wall.\n",
      "82 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "81 bottles of beer on the wall.\n",
      "\n",
      "81 bottles of beer on the wall.\n",
      "81 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "80 bottles of beer on the wall.\n",
      "\n",
      "80 bottles of beer on the wall.\n",
      "80 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "79 bottles of beer on the wall.\n",
      "\n",
      "79 bottles of beer on the wall.\n",
      "79 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "78 bottles of beer on the wall.\n",
      "\n",
      "78 bottles of beer on the wall.\n",
      "78 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "77 bottles of beer on the wall.\n",
      "\n",
      "77 bottles of beer on the wall.\n",
      "77 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "76 bottles of beer on the wall.\n",
      "\n",
      "76 bottles of beer on the wall.\n",
      "76 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "75 bottles of beer on the wall.\n",
      "\n",
      "75 bottles of beer on the wall.\n",
      "75 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "74 bottles of beer on the wall.\n",
      "\n",
      "74 bottles of beer on the wall.\n",
      "74 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "73 bottles of beer on the wall.\n",
      "\n",
      "73 bottles of beer on the wall.\n",
      "73 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "72 bottles of beer on the wall.\n",
      "\n",
      "72 bottles of beer on the wall.\n",
      "72 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "71 bottles of beer on the wall.\n",
      "\n",
      "71 bottles of beer on the wall.\n",
      "71 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "70 bottles of beer on the wall.\n",
      "\n",
      "70 bottles of beer on the wall.\n",
      "70 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "69 bottles of beer on the wall.\n",
      "\n",
      "69 bottles of beer on the wall.\n",
      "69 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "68 bottles of beer on the wall.\n",
      "\n",
      "68 bottles of beer on the wall.\n",
      "68 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "67 bottles of beer on the wall.\n",
      "\n",
      "67 bottles of beer on the wall.\n",
      "67 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "66 bottles of beer on the wall.\n",
      "\n",
      "66 bottles of beer on the wall.\n",
      "66 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "65 bottles of beer on the wall.\n",
      "\n",
      "65 bottles of beer on the wall.\n",
      "65 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "64 bottles of beer on the wall.\n",
      "\n",
      "64 bottles of beer on the wall.\n",
      "64 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "63 bottles of beer on the wall.\n",
      "\n",
      "63 bottles of beer on the wall.\n",
      "63 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "62 bottles of beer on the wall.\n",
      "\n",
      "62 bottles of beer on the wall.\n",
      "62 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "61 bottles of beer on the wall.\n",
      "\n",
      "61 bottles of beer on the wall.\n",
      "61 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "60 bottles of beer on the wall.\n",
      "\n",
      "60 bottles of beer on the wall.\n",
      "60 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "59 bottles of beer on the wall.\n",
      "\n",
      "59 bottles of beer on the wall.\n",
      "59 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "58 bottles of beer on the wall.\n",
      "\n",
      "58 bottles of beer on the wall.\n",
      "58 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "57 bottles of beer on the wall.\n",
      "\n",
      "57 bottles of beer on the wall.\n",
      "57 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "56 bottles of beer on the wall.\n",
      "\n",
      "56 bottles of beer on the wall.\n",
      "56 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "55 bottles of beer on the wall.\n",
      "\n",
      "55 bottles of beer on the wall.\n",
      "55 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "54 bottles of beer on the wall.\n",
      "\n",
      "54 bottles of beer on the wall.\n",
      "54 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "53 bottles of beer on the wall.\n",
      "\n",
      "53 bottles of beer on the wall.\n",
      "53 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "52 bottles of beer on the wall.\n",
      "\n",
      "52 bottles of beer on the wall.\n",
      "52 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "51 bottles of beer on the wall.\n",
      "\n",
      "51 bottles of beer on the wall.\n",
      "51 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "50 bottles of beer on the wall.\n",
      "\n",
      "50 bottles of beer on the wall.\n",
      "50 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "49 bottles of beer on the wall.\n",
      "\n",
      "49 bottles of beer on the wall.\n",
      "49 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "48 bottles of beer on the wall.\n",
      "\n",
      "48 bottles of beer on the wall.\n",
      "48 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "47 bottles of beer on the wall.\n",
      "\n",
      "47 bottles of beer on the wall.\n",
      "47 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "46 bottles of beer on the wall.\n",
      "\n",
      "46 bottles of beer on the wall.\n",
      "46 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "45 bottles of beer on the wall.\n",
      "\n",
      "45 bottles of beer on the wall.\n",
      "45 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "44 bottles of beer on the wall.\n",
      "\n",
      "44 bottles of beer on the wall.\n",
      "44 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "43 bottles of beer on the wall.\n",
      "\n",
      "43 bottles of beer on the wall.\n",
      "43 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "42 bottles of beer on the wall.\n",
      "\n",
      "42 bottles of beer on the wall.\n",
      "42 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "41 bottles of beer on the wall.\n",
      "\n",
      "41 bottles of beer on the wall.\n",
      "41 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "40 bottles of beer on the wall.\n",
      "\n",
      "40 bottles of beer on the wall.\n",
      "40 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "39 bottles of beer on the wall.\n",
      "\n",
      "39 bottles of beer on the wall.\n",
      "39 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "38 bottles of beer on the wall.\n",
      "\n",
      "38 bottles of beer on the wall.\n",
      "38 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "37 bottles of beer on the wall.\n",
      "\n",
      "37 bottles of beer on the wall.\n",
      "37 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "36 bottles of beer on the wall.\n",
      "\n",
      "36 bottles of beer on the wall.\n",
      "36 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "35 bottles of beer on the wall.\n",
      "\n",
      "35 bottles of beer on the wall.\n",
      "35 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "34 bottles of beer on the wall.\n",
      "\n",
      "34 bottles of beer on the wall.\n",
      "34 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "33 bottles of beer on the wall.\n",
      "\n",
      "33 bottles of beer on the wall.\n",
      "33 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "32 bottles of beer on the wall.\n",
      "\n",
      "32 bottles of beer on the wall.\n",
      "32 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "31 bottles of beer on the wall.\n",
      "\n",
      "31 bottles of beer on the wall.\n",
      "31 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "30 bottles of beer on the wall.\n",
      "\n",
      "30 bottles of beer on the wall.\n",
      "30 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "29 bottles of beer on the wall.\n",
      "\n",
      "29 bottles of beer on the wall.\n",
      "29 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "28 bottles of beer on the wall.\n",
      "\n",
      "28 bottles of beer on the wall.\n",
      "28 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "27 bottles of beer on the wall.\n",
      "\n",
      "27 bottles of beer on the wall.\n",
      "27 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "26 bottles of beer on the wall.\n",
      "\n",
      "26 bottles of beer on the wall.\n",
      "26 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "25 bottles of beer on the wall.\n",
      "\n",
      "25 bottles of beer on the wall.\n",
      "25 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "24 bottles of beer on the wall.\n",
      "\n",
      "24 bottles of beer on the wall.\n",
      "24 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "23 bottles of beer on the wall.\n",
      "\n",
      "23 bottles of beer on the wall.\n",
      "23 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "22 bottles of beer on the wall.\n",
      "\n",
      "22 bottles of beer on the wall.\n",
      "22 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "21 bottles of beer on the wall.\n",
      "\n",
      "21 bottles of beer on the wall.\n",
      "21 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "20 bottles of beer on the wall.\n",
      "\n",
      "20 bottles of beer on the wall.\n",
      "20 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "19 bottles of beer on the wall.\n",
      "\n",
      "19 bottles of beer on the wall.\n",
      "19 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "18 bottles of beer on the wall.\n",
      "\n",
      "18 bottles of beer on the wall.\n",
      "18 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "17 bottles of beer on the wall.\n",
      "\n",
      "17 bottles of beer on the wall.\n",
      "17 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "16 bottles of beer on the wall.\n",
      "\n",
      "16 bottles of beer on the wall.\n",
      "16 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "15 bottles of beer on the wall.\n",
      "\n",
      "15 bottles of beer on the wall.\n",
      "15 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "14 bottles of beer on the wall.\n",
      "\n",
      "14 bottles of beer on the wall.\n",
      "14 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "13 bottles of beer on the wall.\n",
      "\n",
      "13 bottles of beer on the wall.\n",
      "13 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "12 bottles of beer on the wall.\n",
      "\n",
      "12 bottles of beer on the wall.\n",
      "12 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "11 bottles of beer on the wall.\n",
      "\n",
      "11 bottles of beer on the wall.\n",
      "11 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "10 bottles of beer on the wall.\n",
      "\n",
      "10 bottles of beer on the wall.\n",
      "10 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "9 bottles of beer on the wall.\n",
      "\n",
      "9 bottles of beer on the wall.\n",
      "9 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "8 bottles of beer on the wall.\n",
      "\n",
      "8 bottles of beer on the wall.\n",
      "8 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "7 bottles of beer on the wall.\n",
      "\n",
      "7 bottles of beer on the wall.\n",
      "7 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "6 bottles of beer on the wall.\n",
      "\n",
      "6 bottles of beer on the wall.\n",
      "6 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "5 bottles of beer on the wall.\n",
      "\n",
      "5 bottles of beer on the wall.\n",
      "5 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "4 bottles of beer on the wall.\n",
      "\n",
      "4 bottles of beer on the wall.\n",
      "4 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "3 bottles of beer on the wall.\n",
      "\n",
      "3 bottles of beer on the wall.\n",
      "3 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "2 bottles of beer on the wall.\n",
      "\n",
      "2 bottles of beer on the wall.\n",
      "2 bottles of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "1 bottle of beer on the wall.\n",
      "\n",
      "1 bottle of beer on the wall.\n",
      "1 bottle of beer\n",
      "Take one down.\n",
      "Pass it around\n",
      "No more bottles of beer on the wall.\n"
     ]
    }
   ],
   "source": [
    "word = \"bottles\"  # 将值\"bottles\"（一个字符串）赋给一个名为\"word\"的新变量\n",
    "\n",
    "for beer_num in range(99,0,-1): \n",
    "    \n",
    "    # 循环指定的次数，从99倒数到0. 使用“beer_num”作为循环迭代变量\n",
    "    \n",
    "    print(beer_num,word,\"of beer on the wall.\")\n",
    "    print(beer_num,word,\"of beer\" )\n",
    "    print(\"Take one down.\")\n",
    "    print(\"Pass it around\")\n",
    "    \n",
    "    # 这四个print函数调用显示当前迭代的歌词\"99 bottles of beer on the wall.99 bottles of beer.Take one down.Pass it around.\",每次迭代时类推。\n",
    "    \n",
    "    if beer_num == 1:\n",
    "        print(\"No more bottles of beer on the wall.\")\n",
    "         # 查看是否是最后一轮（变量=1），如果是，则执行print语句并结束歌词\n",
    "    \n",
    "    else:   \n",
    "        # 否则执行以下代码\n",
    "        \n",
    "        new_num = beer_num - 1 \n",
    "         # 把下一瓶啤酒的编号记在另一个变量\"new_num\"中。\n",
    "        \n",
    "        if new_num == 1:  \n",
    "             # 如果新的变量=1，则执行以下print语句\n",
    "            \n",
    "            word = \"bottle\"  \n",
    "            # 修改“word”变量的值，使得最后一行歌词没有错误\n",
    "            \n",
    "        print(new_num, word, \"of beer on the wall.\") \n",
    "        #执行完这一次迭代的歌词\n",
    "        \n",
    "        print()\n",
    "        # 这次迭代的最后，打印一个空行。所有迭代完成后，终止程序"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8eeb8f73",
   "metadata": {},
   "source": [
    "### 课堂上的补充"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "640c40b1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottles 在啤酒墙上~~~\n",
      "99 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "98 bottles 在啤酒墙上~~~\n",
      "98 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "97 bottles 在啤酒墙上~~~\n",
      "97 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "96 bottles 在啤酒墙上~~~\n",
      "96 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "95 bottles 在啤酒墙上~~~\n",
      "95 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "94 bottles 在啤酒墙上~~~\n",
      "94 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "93 bottles 在啤酒墙上~~~\n",
      "93 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "92 bottles 在啤酒墙上~~~\n",
      "92 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "91 bottles 在啤酒墙上~~~\n",
      "91 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "90 bottles 在啤酒墙上~~~\n",
      "90 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "89 bottles 在啤酒墙上~~~\n",
      "89 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "88 bottles 在啤酒墙上~~~\n",
      "88 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "87 bottles 在啤酒墙上~~~\n",
      "87 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "86 bottles 在啤酒墙上~~~\n",
      "86 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "85 bottles 在啤酒墙上~~~\n",
      "85 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "84 bottles 在啤酒墙上~~~\n",
      "84 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "83 bottles 在啤酒墙上~~~\n",
      "83 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "82 bottles 在啤酒墙上~~~\n",
      "82 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "81 bottles 在啤酒墙上~~~\n",
      "81 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "80 bottles 在啤酒墙上~~~\n",
      "80 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "79 bottles 在啤酒墙上~~~\n",
      "79 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "78 bottles 在啤酒墙上~~~\n",
      "78 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "77 bottles 在啤酒墙上~~~\n",
      "77 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "76 bottles 在啤酒墙上~~~\n",
      "76 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "75 bottles 在啤酒墙上~~~\n",
      "75 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "74 bottles 在啤酒墙上~~~\n",
      "74 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "73 bottles 在啤酒墙上~~~\n",
      "73 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "72 bottles 在啤酒墙上~~~\n",
      "72 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "71 bottles 在啤酒墙上~~~\n",
      "71 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "70 bottles 在啤酒墙上~~~\n",
      "70 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "69 bottles 在啤酒墙上~~~\n",
      "69 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "68 bottles 在啤酒墙上~~~\n",
      "68 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "67 bottles 在啤酒墙上~~~\n",
      "67 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "66 bottles 在啤酒墙上~~~\n",
      "66 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "65 bottles 在啤酒墙上~~~\n",
      "65 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "64 bottles 在啤酒墙上~~~\n",
      "64 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "63 bottles 在啤酒墙上~~~\n",
      "63 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "62 bottles 在啤酒墙上~~~\n",
      "62 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "61 bottles 在啤酒墙上~~~\n",
      "61 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "60 bottles 在啤酒墙上~~~\n",
      "60 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "59 bottles 在啤酒墙上~~~\n",
      "59 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "58 bottles 在啤酒墙上~~~\n",
      "58 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "57 bottles 在啤酒墙上~~~\n",
      "57 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "56 bottles 在啤酒墙上~~~\n",
      "56 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "55 bottles 在啤酒墙上~~~\n",
      "55 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "54 bottles 在啤酒墙上~~~\n",
      "54 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "53 bottles 在啤酒墙上~~~\n",
      "53 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "52 bottles 在啤酒墙上~~~\n",
      "52 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "51 bottles 在啤酒墙上~~~\n",
      "51 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "50 bottles 在啤酒墙上~~~\n",
      "50 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "49 bottles 在啤酒墙上~~~\n",
      "49 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "48 bottles 在啤酒墙上~~~\n",
      "48 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "47 bottles 在啤酒墙上~~~\n",
      "47 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "46 bottles 在啤酒墙上~~~\n",
      "46 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "45 bottles 在啤酒墙上~~~\n",
      "45 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "44 bottles 在啤酒墙上~~~\n",
      "44 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "43 bottles 在啤酒墙上~~~\n",
      "43 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "42 bottles 在啤酒墙上~~~\n",
      "42 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "41 bottles 在啤酒墙上~~~\n",
      "41 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "40 bottles 在啤酒墙上~~~\n",
      "40 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "39 bottles 在啤酒墙上~~~\n",
      "39 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "38 bottles 在啤酒墙上~~~\n",
      "38 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "37 bottles 在啤酒墙上~~~\n",
      "37 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "36 bottles 在啤酒墙上~~~\n",
      "36 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "35 bottles 在啤酒墙上~~~\n",
      "35 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "34 bottles 在啤酒墙上~~~\n",
      "34 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "33 bottles 在啤酒墙上~~~\n",
      "33 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "32 bottles 在啤酒墙上~~~\n",
      "32 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "31 bottles 在啤酒墙上~~~\n",
      "31 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "30 bottles 在啤酒墙上~~~\n",
      "30 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "29 bottles 在啤酒墙上~~~\n",
      "29 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "28 bottles 在啤酒墙上~~~\n",
      "28 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "27 bottles 在啤酒墙上~~~\n",
      "27 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "26 bottles 在啤酒墙上~~~\n",
      "26 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "25 bottles 在啤酒墙上~~~\n",
      "25 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "24 bottles 在啤酒墙上~~~\n",
      "24 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "23 bottles 在啤酒墙上~~~\n",
      "23 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "22 bottles 在啤酒墙上~~~\n",
      "22 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "21 bottles 在啤酒墙上~~~\n",
      "21 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "20 bottles 在啤酒墙上~~~\n",
      "20 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "19 bottles 在啤酒墙上~~~\n",
      "19 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "18 bottles 在啤酒墙上~~~\n",
      "18 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "17 bottles 在啤酒墙上~~~\n",
      "17 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "16 bottles 在啤酒墙上~~~\n",
      "16 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "15 bottles 在啤酒墙上~~~\n",
      "15 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "14 bottles 在啤酒墙上~~~\n",
      "14 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "13 bottles 在啤酒墙上~~~\n",
      "13 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "12 bottles 在啤酒墙上~~~\n",
      "12 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "11 bottles 在啤酒墙上~~~\n",
      "11 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "10 bottles 在啤酒墙上~~~\n",
      "10 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "9 bottles 在啤酒墙上~~~\n",
      "9 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "8 bottles 在啤酒墙上~~~\n",
      "8 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "7 bottles 在啤酒墙上~~~\n",
      "7 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "6 bottles 在啤酒墙上~~~\n",
      "6 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "5 bottles 在啤酒墙上~~~\n",
      "5 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "4 bottles 在啤酒墙上~~~\n",
      "4 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "3 bottles 在啤酒墙上~~~\n",
      "3 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "\n",
      "2 bottles 在啤酒墙上~~~\n",
      "2 bottles 啤酒~~\n",
      "拿一瓶走~~~\n",
      "1 bottle 在啤酒墙上\n",
      "\n",
      "1 bottle 在啤酒墙上~~~\n",
      "1 bottle 啤酒~~\n",
      "拿一瓶走~~~\n",
      "只剩一瓶了，不能给你了！\n"
     ]
    }
   ],
   "source": [
    "word = \"bottles\"\n",
    "\n",
    "for beer_num in range(99,0,-1):\n",
    "    print(beer_num,word,\"在啤酒墙上~~~\")\n",
    "    print(beer_num,word,\"啤酒~~\")\n",
    "    print(\"拿一瓶走~~~\")\n",
    "    if beer_num == 1:\n",
    "        print(\"只剩一瓶了，不能给你了！\")\n",
    "    else:\n",
    "        new_num = beer_num - 1\n",
    "        if new_num == 1:\n",
    "            word = \"bottle\"\n",
    "            print(new_num,word,\"在啤酒墙上\")\n",
    "        print()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
